<%@ page contentType="text/html;charset=UTF-8"%>
<%@ page import="java.util.Vector,com.ejoysoft.wlanyz.business.Task,com.ejoysoft.common.Constants,com.ejoysoft.common.exception.NoRightException" %>
<%@page import="sun.reflect.generics.tree.IntSignature"%>
<%@page import="com.ejoysoft.common.Format"%>
<%@ include file="../include/jsp/head.jsp"%>
<%
if(!globa.userSession.hasRight("10020"))
      throw new NoRightException("用户不具备操作该功能模块的权限，请与系统管理员联系！");
 
    //初始化
    Task  task0=null;
    Task obj=new Task(globa);
    //查询条件
    String strTaskMan= ParamUtil.getString(request,"strTaskMan","");
    String strTaskPhone=ParamUtil.getString(request,"strTaskPhone","");
     String strTaskName= ParamUtil.getString(request,"strTaskName","");
    String strTaskType=ParamUtil.getString(request,"strTaskType","");
   
    	//当前页
	int intCurPage= Integer.parseInt(ParamUtil.getString(request,"strCurPage","1"));
	String tWhere=" WHERE 1=1";
	if(!strTaskMan.equals("")){
     tWhere += " and strTaskMan LIKE '%"+ strTaskMan +"%'";
    }
	if (!strTaskName.equals("")) {
		tWhere += " and strTaskName LIKE '%" + strTaskName + "%'";
	}
	if(!strTaskPhone.equals("")){
     tWhere += " and strTaskPhone = '"+ strTaskPhone +"'";
    }
	if (!strTaskType.equals("")) {
		tWhere += " and strTaskType = '" + strTaskType + "'";
	}
	
	
	String checked1 =  ParamUtil.getString(request,"checkedFlag","all"); 
	if(checked1.equals("checked")){
	  tWhere += " and checkedLocation is not null and checkedLocation <>' ' ";
	}
	else if(checked1.equals("unchecked")){
	  tWhere += " and checkedLocation is null or checkedLocation =' '";
	}
	 tWhere += " ORDER BY strTaskMan";

	//记录总数
	int intAllCount=obj.getCount(tWhere);	

	//每页记录数
	String strPageSize = ParamUtil.getString(request,"strPageSize","10");
    int intPageSize;
    if(strPageSize.equals("所有"))intPageSize = intAllCount;
      else  intPageSize = Integer.parseInt(strPageSize);
	//共有页数
 	int intPageCount=(intAllCount-1)/intPageSize+1;
	// 循环显示一页内的记录 开始序号
	int intStartNum=(intCurPage-1)*intPageSize+1;
	//结束序号
	int intEndNum=intCurPage*intPageSize;   
	//获取到当前页面的记录集
	Vector<Task> vctObj=obj.list(tWhere,intStartNum,intPageSize);
	//获取当前页的记录条数
	int intVct=(vctObj!=null&&vctObj.size()>0?vctObj.size():0);
	
	String exportContent = ParamUtil.getString(request,"exportContent","");
		if(exportContent.equals("allPage"))
		{
			vctObj=obj.list(tWhere,0,0);
		}
   	   	StringBuffer sb = new StringBuffer("<html><body><table  border=1>");
	    sb.append("<tr><td>测试人</td><td>测试手机号</td><td>热点名称</td><td>任务名称</td><td>任务类型</td><td>网络类型</td><td>任务时限</td><td>测试次数</td><td>是否下发</td></tr>");
	    
	    if (vctObj.size() != 0)
	    {
		    for (int i = 0; i < vctObj.size(); i++)
		    {
            	 sb.append("<tr><td>"+(vctObj.get(i).getStrTaskMan()==null?" ":vctObj.get(i).getStrTaskMan()));
		       sb.append("</td><td>");
		       sb.append((vctObj.get(i).getStrTaskPhone()==null?" ":vctObj.get(i).getStrTaskPhone()));
		       sb.append( "</td><td>");
		       sb.append((vctObj.get(i).getStrHotpotName()==null?" ":vctObj.get(i).getStrHotpotName()));
		       sb.append( "</td><td>");
		       sb.append((vctObj.get(i).getStrTaskName()==null?" ":vctObj.get(i).getStrTaskName()));
		       sb.append( "</td><td>");
		       sb.append((vctObj.get(i).getStrTaskType()==null?" ":vctObj.get(i).getStrTaskType()));
		       sb.append( "</td><td>");
               sb.append((vctObj.get(i).getStrNetType()==null?" ":vctObj.get(i).getStrNetType()));
               sb.append("</td><td>");
               sb.append(((vctObj.get(i).getDtStartTime()==null)||(vctObj.get(i).getDtEndTime()==null))?" ":vctObj.get(i).getDtStartTime()+"———"+vctObj.get(i).getDtEndTime());
               sb.append( "</td><td>");
		        sb.append(vctObj.get(i).getStrTestCount());
               sb.append("</td><td>");
                sb.append((vctObj.get(i).getIntIssued()==0)?"未下发":"已下发");
               sb.append("</td></tr>");
		        
		    }
	    } 
	    sb.append("</table></body></html>");
	    String strFileName = "任务信息核查表.xls";//自定义csv文件的文件名
	    response.setContentType("APPLICATION/*");
	    response.setHeader( "Content-Disposition", "attachment;filename="  + new String( strFileName.getBytes("gbk"), "ISO8859-1" ));
	    out.clearBuffer(); 
	    out = pageContext.pushBody();
	    ServletOutputStream output = response.getOutputStream();
	    output.write(sb.toString().getBytes());
	    globa.closeCon();
	    
%>
<%@ include file="../include/jsp/footer.jsp"%>
